<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{#if $result.tid}编辑{#else}发表{#/if}文章</title>
<link href="/theme/default/css.css" type="text/css" rel="stylesheet"/>
<!-- 载入Jquery框架 -->
<script src="/js/jquery-1.7.1.min.js" type="text/javascript"></script>
<!-- 载入Jquery消息提示框架 -->
<script src="/js/lhgdialog/lhgdialog.min.js" type="text/javascript"></script>
<!-- 载入Jquery表单插件 -->
<script src="/js/jquery.form.js"></script>
<!-- 载入Kindeditor编辑器 -->
<script charset="utf-8" src="/js/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="/js/kindeditor/lang/zh_CN.js"></script>
<!-- 载入Select样式脚本 -->
<script charset="utf-8" src="/js/jQselect.js"></script>
<script type="text/javascript"> 
//初始化Kindeditor框架
var editor;
KindEditor.ready(function(K) {
		editor = K.create('#content');
});
$(document).ready(function() {
	//从定义select样式
	$("#cateid").selectbox();
	//设置Ajax属性
	var options = { 
		target: '#space-box', 
		beforeSubmit: checkform,
		url: '{#spUrl c=main a=post}', 
		success: function(data){
			//$("#submit").attr("disabled", false);
			$("#space-box").show();
			$("#space-box").fadeOut(1000);
			if (data == '0') {
				alert('添加失败');
			} else {
				setTimeout("location='index.php'",500); 
			}
		},
	};
	$('#form1').ajaxForm(options);
	
	//表单验证函数
	function checkform(){
		//验证标题
		if ($("#title").val() == '') {
			formAlert('请填写标题');
			return false;	
		}
		//验证内容
		if ($("#content").val() == '') {
			formAlert('请填写内容');
			return false;	
		}
		$("#submit").attr("disabled", true);
		return true;
	}
	
	//通用提示函数
	function formAlert($message) {
		$.dialog({
			lock: true,
			opacity: 0.6,
			title: '提示信息',
			content: $message,
			icon: 'alert.gif',
			max: false,
			min: false
		});
	}
});

</script>

</head>

<body>
{#include file='header.html'}

<div class="pub-panel">
	<div id="space-box"></div>
	<h3>{#if $result.tid}编辑{#else}发表{#/if}文章</h3>
	<form id="form1" name="form1" method="post" action="{#spUrl c=main a=post}">
    	<input name="tid" type="hidden" id="tid" value="{#$result.tid}" />
		<p class="pub-panel-1">
        	<span class="pub-panel-1-left"><b>存放于：</b><select name="cateid" id="cateid">{#section name=n loop=$results}<option value="{#$results[n].cateid}" {#if $result.cateid == $results[n].cateid}selected="selected"{#/if}>{#$results[n].catename}</option>{#/section}</select></span>
            <span class="pub-panel-1-right"><b>标题（必填）：</b><input type="text" name="title" id="title" value="{#$result.title}" /></span>
        </p>
        <p><strong>内容（必填）：</strong><br /><textarea name="content" id="content" style="width:700px;height:300px;visibility:hidden;">{#$result.cms_article_data.content}</textarea></p>
        <p><strong>标签：</strong><br /><input type="text" name="tag" id="tag"  size="40" value="{#$result.tag}"/><span class="gray">多个标签使用空格隔开，最多填写5个标签</span></p>
        <p align="right"><input type="submit" name="submit" id="submit" value="{#if $result.tid}编辑{#else}发表{#/if}"/></p>
	</form>
</div>

</body>
</html>
